package com.weibo.boot.springbootlearn.controller;

import com.weibo.boot.springbootlearn.dao.mapper.UserMapper;
import com.weibo.boot.springbootlearn.mq.kafka.KafkaProducer;
import com.weibo.boot.springbootlearn.service.facade.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

@RestController
@RequestMapping("/index")
@Slf4j
public class IndexController {


    @Resource
    private UserMapper userMapper;

    @Resource
    private KafkaProducer kafkaProducer;

    @Reference(version = "${dubbo.service.version}")
    private ProductService helloService;

    @GetMapping("/hello")
    public String index() {
        String consumer = helloService.sayHello("consumer");
        System.out.println(consumer);

//        kafkaProducer.send("hello");
//        User user = userMapper.selectByPrimaryKey(3L);
//        log.info("{}", JSON.toJSONString(user));
        return "hello world; now time is :" + new Date();
    }

}
